#include <iostream>
#include "AutoPointer.h"

using namespace std;

/**
 * 智能指针
 */
class TestAutoPointer {
public:
    /**
     * 析构函数
     */
    ~TestAutoPointer() {
        cout << "delete pointer" << endl;
    }

    void Hello() {
        cout << "hello" << endl;
    }

};

void Fun1() {
    AutoPointer<TestAutoPointer> test(new TestAutoPointer);
    if (test) {
        test->Hello();
    }

}

int main() {
    cout << "Hello, World!" << endl;

    // 测试指针回收
    for (int i = 0; i < 10; ++i) {
        Fun1();
    }

    return 0;
}
